package com.ruoyi.security.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.security.mapper.AfDataAcquirementMapper;
import com.ruoyi.security.domain.AfDataAcquirement;
import com.ruoyi.security.service.IAfDataAcquirementService;

/**
 * 数据采集Service业务层处理
 *
 * @author cjie
 * @date 2021-07-24
 */
@Service
public class AfDataAcquirementServiceImpl implements IAfDataAcquirementService {
    @Autowired
    private AfDataAcquirementMapper afDataAcquirementMapper;

    /**
     * 查询数据采集
     *
     * @param id 数据采集ID
     * @return 数据采集
     */
    @Override
    public AfDataAcquirement selectAfDataAcquirementById(String id) {
        return afDataAcquirementMapper.selectAfDataAcquirementById(id);
    }

    /**
     * 查询数据采集列表
     *
     * @param afDataAcquirement 数据采集
     * @return 数据采集
     */
    @Override
    public List<AfDataAcquirement> selectAfDataAcquirementList(AfDataAcquirement afDataAcquirement) {
        return afDataAcquirementMapper.selectAfDataAcquirementList(afDataAcquirement);
    }

    /**
     * 新增数据采集
     *
     * @param afDataAcquirement 数据采集
     * @return 结果
     */
    @Override
    public int insertAfDataAcquirement(AfDataAcquirement afDataAcquirement) {
        afDataAcquirement.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        afDataAcquirement.setCreateTime(DateUtils.getNowDate());
        afDataAcquirement.setCreateBy(SecurityUtils.getUsername());
        return afDataAcquirementMapper.insertAfDataAcquirement(afDataAcquirement);
    }

    /**
     * 修改数据采集
     *
     * @param afDataAcquirement 数据采集
     * @return 结果
     */
    @Override
    public int updateAfDataAcquirement(AfDataAcquirement afDataAcquirement) {
        afDataAcquirement.setUpdateTime(DateUtils.getNowDate());
        afDataAcquirement.setUpdateBy(SecurityUtils.getUsername());
        return afDataAcquirementMapper.updateAfDataAcquirement(afDataAcquirement);
    }

    /**
     * 批量删除数据采集
     *
     * @param ids 需要删除的数据采集ID
     * @return 结果
     */
    @Override
    public int deleteAfDataAcquirementByIds(String[] ids) {
        return afDataAcquirementMapper.deleteAfDataAcquirementByIds(ids);
    }

    /**
     * 删除数据采集信息
     *
     * @param id 数据采集ID
     * @return 结果
     */
    @Override
    public int deleteAfDataAcquirementById(String id) {
        return afDataAcquirementMapper.deleteAfDataAcquirementById(id);
    }
}
